<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <h1>Element.innerHTML属性</h1>

    <input type="button" value="清空body" onclick=" clearBody()">

    <input type="button" value='"<" 字符为 HTML 实体 "&lt;", 显示源码' onclick=" fn()">


</body>
<script>

    function clearBody() {
        document.body.innerHTML = "";
    }


    function fn() {
        let replace = document.documentElement.innerHTML.replace(/</g,"&lt;");
        console.log(replace);
        document.documentElement.innerHTML = "<pre>" + replace + "</pre>";

    }


</script>


</html>